package com.example.intenttactivity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class Main2Activity extends AppCompatActivity {
    private Button intentbtn2;
    private TextView txtmain2;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        initView();
        setListener();
    }
    private void setListener(){
        intentbtn2.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v){
                Intent intent=new Intent();
                intent.putExtra("result","这是第二个Activity传回的信息");
                setResult(2,intent);
                finish();

            }
        });

    }
    private void initView(){
        intentbtn2=findViewById(R.id.intentbtn2);
        txtmain2=findViewById(R.id.textmain2);
    }
}
